.text
.section	.rodata
.align 8
.LC0:
	.string	"Please enter an integer to be summed "
.LC1:
	.string	"(q to quit): "
.LC2:
	.string	"%ld"
	.align 8
.LC3:
	.string	"Please enter next integer (q to quit): "
.text
.globl	main
.type	main, @function
main:
	endbr64
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)

	xorl	%eax, %eax
	// sum
	movq	$0, -16(%rbp)

	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT

	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT

	// num
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf
	// status = 返回值
	movl	%eax, -28(%rbp)
	jmp	.L2
.L5:
	movq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf
	movl	%eax, -28(%rbp)
.L2:
	// status = 1
	movl	$1, -28(%rbp)
	// 这里其实应该判断status是不是为1，但是编译器判定永远为真，所以直接跳转，没有条件跳转
	jmp	.L5
